﻿using System;
using System.Collections.Generic;
using System.Text;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Exceptions;
using SchEdu.Framework.Logging;

namespace SchEdu.Framework.DataModel
{
    public class Slack : ISlack
    {
        private Logger logger = new Logger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString());

        protected Logger Logger
        {
            get { return logger; }
            set { logger = value; }
        }



        #region ISlack Members

        public int GetSlack(SchEduDataSet.OrderRow order, int t)
        {
            return  Math.Max((order.DueDate - order.ProcessingTime - t), 0);
        }

        public int GetSlack(SchEduDataSet.OrderRow order, OperationList operations, int t)
        {
            int processingTime = 0;
            foreach (SchEduDataSet.OperationRow operation in operations)
            {
                processingTime += operation.ProcessingTime;
            }
            return Math.Max((order.DueDate - processingTime - t), 0);
        }

        #endregion
    }
}
